﻿@{
    ViewBag.Title = "Authorization";
    Layout = "~/Views/Shared/MyLayout.cshtml";
}

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link href="~/Content/bootstrap/css/style.css" rel="stylesheet" />
<link href="~/Content/bootstrap/css/base.css" rel="stylesheet" />
<script src="~/Scripts/jquery-2.1.1.min.js"></script>
<link href="~/Scripts/datejs/datecss.css" rel="stylesheet" />
<script src="~/Scripts/layer/layer.js"></script>
<script>
    function ok() {
        var pwd = $("#newpwd").val();
        if (ChkIn()) {
            //修改密码
            $.ajax({
                type: "Post",
                url: "/Password/UptPassword",
                data: { "pwd": pwd },
                dataType: "json",
                success: function (data) {
                    if (data.MessageCode == "0") {
                        layer.msg("密码修改成功！");
                        setTimeout(function () {
                            window.location ="/Account/Index";
                        }, 2000)
                    } else {
                        layer.msg("密码修改失败,请稍后再试!");
                        window.location = window.location.href;
                    }
                }
            });
        }
    }
    //验证两次密码是否一致
    function ChkIn() {
        var newpass = $("#newpwd").val();
        var twopass = $("#newspwd").val();
        if (newpass == "") {
            layer.msg('请输入新密码！');
            return false;
        }
        if (newpass != twopass) {
            layer.msg('两次输入的密码不一致！');
            return false;
        }
        return true;
    }
</script>
<div class="rightoverflow">
    <div class="ove-hid">
        <div class="wid-100 cor-4d4 fon-siz20 lin-hei60 bor-bot999">
            <div class="flo-lef">&nbsp;&nbsp;&nbsp;&nbsp;<span><i class="fa fa-gear"></i></span><span>修改密码</span></div>
        </div>
    </div>
    <div class="ove-hid">
        <div class="wid-120 cor-4d4 fon-siz20 lin-hei60 bor-botdcd ">
        </div>
    </div>
    <div class="ove-hid">
        <div class="Rep-main wid-120 mag-top50" style="margin-left:200px;">
            <p style="margin-left:40px; font-weight:bold; ">用户名：<label>@ViewData["user_name"] </label></p>
            <p style="margin-top:30px;">修改密码：<input type="password" id="newpwd" style="height: 30px; width: 50%;" /></p>
            <p style="margin-top:30px;">确认密码：<input type="password" id="newspwd" style="height: 30px; width: 50%;" /></p>
            <p style="margin-top:30px; margin-left:70px;"><input type="button" value="保存" onclick="ok()" style="background-color: #FF8302; border:0; width:10%; height:30px;" /></p>
        </div>
    </div>
</div>
